package com.unicom.office.var;

import com.unicom.office.dataitem.BooleanDataItem;
import com.unicom.office.dataitem.DataItem;
import com.unicom.office.type.BooleanTypeItem;
import com.unicom.office.type.TypeItem;

public class BooleanVarItem extends VarItem {
    public BooleanVarItem(String name) {
        super(name);
    }

    public TypeItem getTypeItem() {
        return BooleanTypeItem.INSTANCE;
    }

    public Object getFormatedValue(Object value) {
        if(value == null) {
            return getDefaultValue();
        }else if(value instanceof Boolean) {
            return (Boolean)value;
        }else {
            return Boolean.valueOf(value.toString());
        }
    }

    public DataItem createDataItem(Object value) {
        return new BooleanDataItem(value, this);
    }
}
